//
// Created by 66477 on 2022/10/5.
//

#ifndef DATA_STRUCTURE_BITREE5_2_H
#define DATA_STRUCTURE_BITREE5_2_H

#include <vector>
#include <iostream>
#include <cstring>
#include "stack"

using namespace std;

class BiTree5_2 {
private:
    vector<char> vec;
public:
    BiTree5_2(string str) {
        for (int i = 0; i < str.length(); ++i) {
            vec.push_back(str[i]);
        }
    }

    void print() {
        stack<int> sta;
        if (vec.empty()) return;
        int idx;
        sta.push(1);
        while (!sta.empty()) {
            idx = sta.top();
            sta.pop();
            cout << vec[idx - 1];
            if (idx * 2 + 1 <= vec.size()) {
                sta.push(idx * 2 + 1);
            }
            if (idx * 2 <= vec.size()) {
                sta.push(idx * 2);
            }
        }
        cout << endl;
    }

};

#endif //DATA_STRUCTURE_BITREE5_2_H
